<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>${name_china}管理列表</title>
<%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
        </div>
        <div id="toolbar" style="float: right"></div>
    </div>
    <div class="page-title-border"></div>
</div>

<div class="search-field">
    <span class="field-cont">
        <span class="field-cont-title">订单号</span>
        <input type="hidden" class="summer-input" id="itemId"/>
        <input type="hidden" class="summer-input" id="expressId"/>
        <input type="text" class="summer-input" id="orderNo"/>
    </span>
    
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span>
</div>

<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="20%">
	    <col width="30%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <thead>
		    <tr>
		    	<th>订单编号</th>
		        <th>商品信息</th>
		        <th>物流公司</th>
		        <th>快递单号</th>
		        <th>操作</th>
		    </tr>
	    </thead>
    </table>
</div>

<script>
	//请求url
	var CONST_URL = {
	   	INIT_EDIT: basePath + "${common_url}initEdit",
	   	UPDATE: basePath + "${common_url}updatelist"
	};
	
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
        // 新建toobar
		$.funcbar({
			id: 'toolbar',
			type: 'toolbar',
			data: permission,
			permit: ['${name_english}:initAdd']
		});
        
		//初始化下拉选项
     	 $('#expressName').combobox({
             valueField : 'code',
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_PROJECT_EXPRESS_EXPRESS_COMPANY'
         });
		
        // 查询按钮
        $('#search').on('click', reloadTable);
        
      //编辑
    	//$('#funcbar').on('click', 'a[data-permit="${name_english}:initEdit"]', update);
        //重置按钮
        $('#reset').on('click', function () {
        	//重置文本框的值
        	$('#orderId').val('');
        	//$('#startTime').val(''); 
        	//$('#stopTime').val('');
        	
        	reloadTable();
        });
       createTable();
        //编辑
        var iWidth;                         //弹出窗口的宽度;
        var iHeight;                        //弹出窗口的高度;
         var iTop = (window.screen.height-60-iHeight)/2;       //获得窗口的垂直位置;
         var iLeft = (window.screen.width-20-iWidth)/2;        //获得窗口的水平位置;
         
        $('#t-wrap').on('click', 'a[data-permit="${name_english}:initEdit"]', function() {
            var $this = $(this),
            itemId = $this.closest('tr').find('td[data-field="itemId"]').attr('data-value');
            window.open (CONST_URL.INIT_EDIT+ '?itemId=' + itemId,'newwindow','height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no') ;
        });	
       
    });
    
    
    // 重新加载表格
	function reloadTable() {
		$('#dataList').datagrid('reload',{
            ajax: {
            	param: {
            		"orderNo": trimSpace($('#orderNo').val())
                	//"startTime": trimSpace($('#startTime').val()),
                	//"stopTime": trimSpace($('#stopTime').val())
            	}
            }
        });
	}
    
    //创建表格
    function createTable() {
    	$('#dataList').datagrid({
    		ajax: {
    			url: CONST_URL.UPDATE,
    			param: {
    				"orderNo": trimSpace($('#orderNo').val())
                	//"startTime": trimSpace($('#startTime').val()),
                	//"stopTime": trimSpace($('#stopTime').val())
            	}
    		},
    		columns: [
    			{
   		    	 field: 'id',
   		    	 hidden: true
   		    	 },
   		    	 {
    		    	 field: 'expressId',
    		    	 hidden: true
    		     },
    		     {
    		    	 field: 'itemId',
    		    	 hidden: true
    		     },
    		     {
    		    	 render: function (rowData) {
    		    		 return '<p>'+rowData.orderNo+'</p>'+
    		    		 '<p>'+rowData.payType+'</p>';
    		    		 }
    		     },
    		     
    		     {
    		    	 render: function (rowData) {
    		    		 return '<p>'+rowData.goodsName+'</p>'+
    		    		 '<p>（商品数量：'+rowData.count+'）</p>';
    		    		 }
    		     },
    		     {
    		    	 field:'expressName'
    		     },
    		     {
    		    	 field:'expressNo'
    		     },
    		     
    		    {
    		    	 render: function (rowData) {
    		    		 return $.funcbar({
    		    			 data: permission,    //请求的数据
    		    			 type: 'text',     //类型
    		    			 display: 2,    //显示数量
    		    			 permit: ['${name_english}:initEdit'] //需要的权限按钮
    		    			 
    		    		 });
    		    	 }
    		    }
    		          
    	    ]
    	});
    }
    
    function closeWindow(object, isReload) 
    {
        object.close();
        isReload===true  && window.location.reload();
    }
   /* function update(){
	   window.open('expressEdit.jsp');
   } */
   
</script>
</body>
</html>